#! /usr/bin/env bash

# Copyright (c) 2024 XDream
# Copyright (c) 2024 bruceshu <shuhuan.bruce@gmail.com>
# 2024-6-30

FFMPEG_UPSTREAM=https://gitee.com/bruce_shu/my-ffmpeg.git
FFMPEG_TAG=v0.0.1

FFMPEG_LOCAL_REPO=extra/ffmpeg

pull_fork()
{
    echo "== pull ffmpeg fork $1 =="
    sh tools/pull-repo-ref.sh $FFMPEG_UPSTREAM ffmpeg-$1 $FFMPEG_LOCAL_REPO
    cd ffmpeg-$1
    git checkout $FFMPEG_TAG -B myffmpeg
    cd -
}

set -e

FF_TARGET=$1

echo "== pull ffmpeg base =="
sh tools/pull-repo-base.sh $FFMPEG_UPSTREAM $FFMPEG_LOCAL_REPO

case "$FF_TARGET" in
    "")
        pull_fork "armv7a"
    ;;
    armv7a|arm64)
        pull_fork $FF_TARGET
    ;;
    arm)
        pull_fork "armv7a"
        pull_fork "arm64"
    ;;
    *)
        echo "unknow arch, $FF_TARGET"
    ;;
esac

sh init-config.sh

